<div id="register" class="login_wrapper">
    <div class="animate form login_form">
        <section class="login_content">
            <form action="javascript:void(0);">
                <h1>*** 管理系统注册</h1>
                <div>
                    <input
                            type="text"
                            v-model="user.userName"
                            class="form-control"
                            placeholder="User Name"
                            required=""
                    />
                </div>
                <div>
                    <input
                            type="text"
                            v-model="user.email"
                            class="form-control"
                            placeholder="User email"
                            required=""
                    />
                </div>
                <div>
                    <input
                            type="password"
                            v-model="user.password"
                            class="form-control"
                            placeholder="Password"
                            required=""
                    />
                </div>
                <div>
                    <a @click="register()" class="btn btn-default submit" href="javascript:void(0);">register in</a>
                    <a class="reset_pass" href="#">Lost your password?</a>
                </div>

                <div class="clearfix"></div>

                <div class="separator">
                    <p class="change_link">
                        <a href="/login" class="to_register"> Login in </a>
                    </p>

                    <div class="clearfix"></div>
                    <br />

                    <div>
                        <h1><i class="fa fa-paw"></i> Java_Spring_Boot</h1>
                        <p>©2022 All Rights Reserved. Using is a Bootstrap 3 template.</p>
                    </div>
                </div>
            </form>
        </section>
    </div>
</div>
<script>

    var loginVue = new Vue({
        el: "#register",
        data: {
            user: {
                userName: "",
                password: "",
                email: "",
                rememberMe: false,
            },
        },
        methods: {
            register: function () {
                if (this.user.userName == "" || this.user.password == "" || this.user.email == "") {
                    layer.msg("Please input user name and password and email", {icon: 0});
                    return;
                }
                var self = this;
                $.ajax({
                    url: "/api/user",
                    type: "post",
                    contentType: "application/json",
                    data: JSON.stringify(self.user),
                    success: function (rs) {
                        if (rs.status == 200) {
                            window.location.href = "/common/dashboard";
                        } else {
                            layer.msg(rs.message, { icon: 0 });
                        }
                    },
                    error: function (data) {
                        layer.alert(data.responseText, { icon: 0 });
                    },
                });
            },
        }
    });
</script>